<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>订单列表</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<div class="container">

    <div class="comm_content">

        <div class="search-box">
            <div style="position:relative">
                <form class="form-inline" id="search_form" onsubmit="return false;">
                    <table>
                        <tbody>
                        <tr>
                            <td>报价单号：<input type="text" class="form-control input-sm w120" name="costCode" maxlength="20"></td>
                            <td>项目名称：<input type="text" class="form-control input-sm w120" name="costName" maxlength="30"></td>
                            <td>客户名称：<input type="text" class="form-control input-sm w120" name="companyName" maxlength="20"></td>
                            <td>创建日期：<input class="form-control input-sm w100" id="startDate" name="startDate" value="" readonly="readonly"   type="text" />
                                ～
                                <input class="form-control input-sm w100" id="endDate" name="endDate" value="" readonly="readonly" type="text" " />
                                <button type="button" class="btn btn-default btn-sm" onclick="timeClear1();">清 空</button>
                            </td>
                            <td style="padding-left: 20px">
                                <button type="button" class="btn btn-primary btn-sm" onclick="cost.search();">查 询</button>&nbsp;&nbsp;
                                <button type="button" class="btn btn-warning btn-sm" onclick="cost.clear();">重 置</button>&nbsp;&nbsp;
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>

        <table id="flex" style="display:none"></table>

    </div>

</div>

<script type="text/javascript">

    $(function () {
        //日期
        $('#startDate').datepicker();
        $('#endDate').datepicker();

        //绑定列表
        cost.bind();
    })

    //清空日期
    function timeClear1() {
        $('#startDate').val('');
        $('#endDate').val('');
    }

    var cost =
    {
        bind: function ()
        {
            $("#flex").flexigrid({
                url:"/invokingAjax-backend/bill/billCost.ajax?operFlg=1",
                dataType: "json",
                colModel : [
                    {display: "操作", width : 120, align: "center"},
                    {display: "状态", width : 70, align: "center"},
                    {display: "报价单号", width : 150, align : "center"},
                    {display: "项目名称", width : 180,align : "center"},
                    {display: "客户名称", width : 180},
                    {display: "面积", width : 80},
                    {display: "涂装体系", width : 80},
                    {display: "有效期", width : 100},
                    {display: "下单日期", width : 150},
                ],
                buttons : [
                    {name: "添加", bclass: "add", onpress : "cost.add"}
                ],
                usepager: true,
                rp: 10,
                useRp: true,
                showTableToggleBtn: true,
                autoload: true
            });
        },

        load: function() {
            $("#flex").flexReload();
        },

        search:function () {
            var dt = $("#search_form").serializeArray();
            $("#flex").flexOptions({newp: 1, params: dt}).flexReload();
        },

        clear: function() {
            document.getElementById('search_form').reset();
            this.search();
        },

        add: function () {
            E.open("/quanliadmin/app/bill/billCost.pscript?operFlg=2", "", {height: 620,width: 1024, top: 10, left: 150});
        },

        detail: function (code) {
            E.open("/quanliadmin/app/bill/billCost.pscript?operFlg=2&code="+code, "", {height: 620,width: 1024, top: 10, left: 150});
        },

        //审核
        audit: function (code) {
            E.confirm('确认审核？',function () {
                E.ajax_post({
                    url : '/invokingAjax-backend/bill/billCost.ajax?operFlg=2',
                    data: {
                        code : code,
                        status : 1
                    },
                    call: function (o) {
                        E.alert(o.message, o.code == 200 ? 2 : 1);
                        cost.load();
                    }
                });
            });
        },

        //取消
        cancel: function (code) {
            E.confirm('确认取消？',function () {
                E.ajax_post({
                    url : '/invokingAjax-backend/bill/billCost.ajax?operFlg=2',
                    data: {
                        code : code,
                        status : 9
                    },
                    call: function (o) {
                        E.alert(o.message, o.code == 200 ? 2 : 1);
                        cost.load();
                    }
                });
            });
        }

    }
</script>

</body>
</html>